<?php $this->load->view('admin/public/head.html', array('css' => array(
    '/assets/admin/css/admin/common.css'
))); ?>
<script>
    var listsData = JSON.parse('<?=json_encode($data)?>');
    var rolesData = JSON.parse('<?=json_encode($roles)?>');
</script>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper admin-user" ng-controller="admin-system-admin">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            系统设置
            <small>后台管理员账号设置</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i>后台首页</a></li>
            <li class="active">管理员列表</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <div class="row">

            <div class="col-md-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">管理员列表</h3>
                        <div class="box-tools">
                            <!--
                            <button type="submit" class="btn btn-info btn-sm" style="background: #00a65a; border: none;" ng-click="showAddModal()"><i class="fa fa-plus"></i> 添加管理员</button>
                            -->
                            <a href="/admin/user/add" type="submit" class="btn btn-info btn-sm" style="background: #00a65a; border: none;"><i class="fa fa-plus"></i> 添加管理员</a>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered">
                            <tr>
                                <th style="width: 20px">#</th>
                                <th class="text-center">头像</th>
                                <th class="text-center">昵称</th>
                                <th class="text-center">角色</th>
                                <th class="text-center">邮箱</th>
                                <th class="text-center">手机</th>
                                <th class="text-center">创建时间</th>
                                <th class="text-center">最后登录</th>
                                <th class="text-center" style="width: 120px">操作</th>
                            </tr>
                            <tr ng-repeat="($index, list) in lists">
                                <td class="text-center" ng-bind="list.id"></td>
                                <td class="text-center">
                                    <img style="width: 30px; height: 30px;"
                                         onerror="this.src='/assets/admin/img/nothumb.png'"
                                         ng-src="{{list.avatar}}" alt="">
                                </td>
                                <td class="text-center">
                                    <a href="/admin/user/edit?id={{list.id}}" ng-bind="list.nickName"></a>
                                </td>
                                <td class="text-center" ng-bind="list.role"></td>
                                <td class="text-center" ng-bind="list.email"></td>
                                <td class="text-center" ng-bind="list.phone"></td>
                                <td class="text-center" ng-bind="list.created"></td>
                                <td class="text-center" ng-bind="list.lastTime"></td>
                                <td>
                                    <a href="/admin/user/edit?id={{list.id}}" class="btn btn-link btn-flat btn-xs"><i class="fa fa-pencil"></i> 编辑</a>
                                    <button class="btn btn-link btn-xs btn-flat" ng-click="delete($index)"><i class="fa fa-trash-o"></i> 删除</button>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>

    </section>
    <!-- /.content -->

    <!-- 模态框 -->
    <div class="modal fade" id="testModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">{{ modalType == 'edit' ? '编辑' : '添加' }}管理员账号</h4>
                </div>
                <div class="modal-body">

                    <div class="row">
                        <div class="col-md-8">
                            <!-- form start -->
                            <form class="form-horizontal">
                                <div class="box-body">
                                    <div class="form-group">
                                        <label for="nickName" class="col-sm-2 control-label">昵称</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" ng-model="detail.nickName" id="nickName" placeholder="昵称">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="email" class="col-sm-2 control-label">邮箱</label>
                                        <div class="col-sm-10">
                                            <input type="email" class="form-control" ng-model="detail.email" id="email" placeholder="电子邮箱">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="password" class="col-sm-2 control-label">密码</label>
                                        <div class="col-sm-10">
                                            <input type="password" class="form-control" ng-model="detail.password" id="password" placeholder="密码">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="phone" class="col-sm-2 control-label">手机</label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="phone" ng-model="detail.phone" placeholder="手机号码">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">角色</label>
                                        <div class="col-sm-10">
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-default btn-flat" ng-bind="detail.role ? detail.role : roles[0]['role']"></button>
                                                <button type="button" class="btn btn-default btn-flat dropdown-toggle" data-toggle="dropdown">
                                                    <span class="caret"></span>
                                                    <span class="sr-only">Toggle Dropdown</span>
                                                </button>
                                                <ul class="dropdown-menu" role="menu">
                                                    <li ng-repeat="(key, role) in roles"><a ng-click="selectRole(key)" ng-bind="role.role"></a></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- /.box-body -->
                            </form>
                        </div>

                        <div class="col-md-4">
                            <div class="form-group">
                                <div class="col-sm-10" style="text-align: center;">
                                    <div class="avatar-box" id="avatar-box">
                                        <img ng-src="{{ detail.showAvatar }}" ng-show="detail.showAvatar != ''" class="avatar" alt="">
                                    </div>
                                    <p class="text-muted text-center">JPG/PNG/GIF 100*100</p>
                                    <button class="btn avatar-btn btn-flat btn-info" style="background: #00a65a; border: none;" id="avatarUploader">选择头像</button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" style="background: #00a65a; border: none;" ng-click="save()">保存</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
    <!-- /.example-modal -->
</div>

<!-- /.content-wrapper -->
<?php $this->load->view('admin/public/foot.html', array('js' => array(
    'http://cdn.staticfile.org/webuploader/0.1.0/webuploader.withoutimage.min.js',
    '/assets/admin/js/admin/admin.js'
))); ?>
